﻿<%@ WebHandler Language="C#" Class="ZSWorkTimeInfoLookBoardHanlder" %>

using System;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Web.SessionState;
using System.IO;
using ReportBusiness;

public class ZSWorkTimeInfoLookBoardHanlder : IHttpHandler
{
    public bool IsReusable { get { return false; } }
    private static uMESZSWorkTimeInfoLookBoardBusiness pdb = new uMESZSWorkTimeInfoLookBoardBusiness();
    public void ProcessRequest(HttpContext context)
    {
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetWorkTimeInfo")
        {
            Dictionary<string, object> para = new Dictionary<string, object>();

            if (context.Request.QueryString["factoryid"] != null)
            {
                para["factoryid"] = EncryptAndDecryptTool.DesDecrypt(context.Request.QueryString["factoryid"].ToString());
            }

            para["startDate"] = (DateTime.Now.Year - 1).ToString() + "/12/21 00:00:00";
            para["endDate"] = DateTime.Now.Year.ToString() + "/12/20 23:59:59";

            DataSet ds = pdb.GetZSWorkTimeInfoLookBoardData(para);

            var totalJson = JsonConvert.SerializeObject(ds.Tables[0]);

            var workcenterJson = JsonConvert.SerializeObject(ds.Tables[1]);

            var everyMonthJson = JsonConvert.SerializeObject(ds.Tables[2]);

            var resultJson = "{\"total\":" + totalJson + ",\"workcenter\":" + workcenterJson + ",\"month\":" + everyMonthJson + "}";

            context.Response.ContentType = "text/json";
            context.Response.Write(resultJson);
            context.Response.End();
        }
    }
}